package org.catj.entity;

import org.catj.property.Trait;

import java.util.*;

public class Dwarf {
    private String name;
    private Map<String, Attribute> attributes = new TreeMap<String, Attribute>();
    private List<Trait> traits = new ArrayList<Trait>();
    private Map<String, Float> jobScores = new TreeMap<String, Float>();
    private Map<Float, Set<String>> sortedJobScores = new TreeMap<Float, Set<String>>();

    public void addJobScore(String jobName, Float score) {
        getJobScores().put(jobName, score);
        Set<String> jobSet;
        if(getSortedJobScores().containsKey(score)){
            jobSet = getSortedJobScores().get(score);
        }
        else{
            jobSet = new TreeSet<String>();
        }
        jobSet.add(jobName);
        getSortedJobScores().put(score, jobSet);
    }

    public Map<Float, Set<String>>  getSortedJobScores() {
        return sortedJobScores;
    }

    public void setSortedJobScores(Map<Float, Set<String>>  sortedJobScores) {
        this.sortedJobScores = sortedJobScores;
    }

    public Float getJobScore(String jobName) {
        return getJobScores().get(jobName);
    }

    public Map<String, Float> getJobScores() {
        return jobScores;
    }

    public void setJobScores(Map<String, Float> jobScores) {
        this.jobScores = jobScores;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Map<String, Attribute> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, Attribute> attributes) {
        this.attributes = attributes;
    }

    public void addAttribute(String name, int value, AttributeScale scale) {
        attributes.put(name, new Attribute(name, value, scale));
    }

    public Attribute getAttribute(String name) {
        return attributes.get(name);
    }

    public void addTrait(String value) {
        traits.add(new Trait(value));
    }

    public List<Trait> getTraits() {
        return traits;
    }

    public void setTraits(List<Trait> traits) {
        this.traits = traits;
    }
}
